#include <iostream>
#include <string>
#include <cstring>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define PATH "FIFO"
#define MODE 0666

class fifo
{
public:
    fifo(const std::string& name)
    : _name(name)
    {
        int ret = mkfifo(_name.c_str(), MODE);
        if (-1 == ret)
        {
            std::cerr << "mkfifo error, " << "errno: " << errno << ", errorstring: " << strerror(errno) << std::endl;
            exit(-1);
        }
        std::cout << "fifo made success" << std::endl;
    }
    ~fifo()
    {
        unlink(_name.c_str());
    }
private:
    const std::string _name;
};


